import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UploadDataTypeConfigForm, UploadDataTypeConfigQuery, UploadDataTypeConfigVO } from './types';

/**
 * 查询设备上报数据类型配置列表
 * @param query
 * @returns {*}
 */

export const listUploadDataTypeConfig = (query?: UploadDataTypeConfigQuery): AxiosPromise<UploadDataTypeConfigVO[]> => {
  return request({
    url: '/iot/uploadDataTypeConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备上报数据类型配置详细
 * @param typeId
 */
export const getUploadDataTypeConfig = (typeId: string | number): AxiosPromise<UploadDataTypeConfigVO> => {
  return request({
    url: '/iot/uploadDataTypeConfig/' + typeId,
    method: 'get'
  });
};

/**
 * 新增设备上报数据类型配置
 * @param data
 */
export const addUploadDataTypeConfig = (data: UploadDataTypeConfigForm) => {
  return request({
    url: '/iot/uploadDataTypeConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备上报数据类型配置
 * @param data
 */
export const updateUploadDataTypeConfig = (data: UploadDataTypeConfigForm) => {
  return request({
    url: '/iot/uploadDataTypeConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备上报数据类型配置
 * @param typeId
 */
export const delUploadDataTypeConfig = (typeId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/uploadDataTypeConfig/' + typeId,
    method: 'delete'
  });
};
